home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / CDimmerCluster / Dimmer srcs / CDimmerApp.cp next >
Encoding:
Text File  |  1995-12-01  |  4.9 KB  |  193 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        CDimmerApp.cp
  3.  
  4.     Contains:    A test harness for the dimmer stuff. See Dimmer.rsrc
  5.                 for the way to use Constructor to define the panes.
  6.  
  7.     Written by:    Sak Wathanasin
  8.                 Network Analysis Ltd
  9.                 178 Wainbody Ave South
  10.                 Coventry CV3 6BX
  11.                 UK
  12.     Phone:        (+44) 203 419996
  13.     E-mail:        sw@network-analysis-ltd.co.uk
  14.  
  15.     Copyright:    © 1995 Network Analysis Ltd. All rights reserved.
  16.  
  17.     Change History (most recent first):
  18.  
  19.     <1.0>        07/08/95    sw        First release.
  20.  
  21.     To Do:
  22. */
  23.  
  24.  
  25. #include "CDimmerApp.h"
  26. #include "CDimmerCluster.h"
  27.  
  28. #include <LWindow.h>
  29. #include <LRadioGroup.h>
  30. #include <LStdControl.h>
  31. #include <LButton.h>
  32.  
  33. #include <PP_Messages.h>
  34. #include <UDrawingState.h>
  35. #include <URegistrar.h>
  36. #include <UReanimator.h>
  37. #include <LGrowZone.h>
  38. #include <UMemoryMgr.h>
  39.  
  40. const    MessageT    cmd_OpenDimmerDlg =    3000;
  41.  
  42. const    ResIDT    rDimmerDlgID         =    1000;
  43. const    ResIDT    rRidLDimmerControls     =    1001;
  44.  
  45. const    ResIDT    rOK                     =    'BtOK';
  46. const    ResIDT    rCancel                 =    'BtCn';
  47. const    ResIDT    rDimmerViewID         =    'topV';
  48. const    ResIDT    rEnableCBID             =    'CBEn';
  49.  
  50.  
  51. const    MessageT    cDisableCluster     =    5000;
  52.  
  53.  
  54. // ===========================================================================
  55. //        • Main Program
  56. // ===========================================================================
  57.  
  58. void main(void)
  59. {
  60.                                     // Set Debugging options
  61.     SetDebugThrow_(debugAction_Alert);
  62.     SetDebugSignal_(debugAction_Alert);
  63.  
  64.     InitializeHeap(4);
  65.     UQDGlobals::InitializeToolbox(&qd);
  66.     new LGrowZone(20000);
  67.  
  68.     CDimmerApp    theApp;
  69.     theApp.Run();
  70. }
  71.  
  72.  
  73. // ---------------------------------------------------------------------------
  74. //        • CDimmerApp
  75. // ---------------------------------------------------------------------------
  76. //    Constructor
  77.  
  78. CDimmerApp::CDimmerApp()
  79. {
  80. //        Register functions to create core PowerPlant classes
  81.     
  82.     URegistrar::RegisterClass(LWindow::class_ID, LWindow::CreateWindowStream);
  83.     URegistrar::RegisterClass(LDialogBox::class_ID, LDialogBox::CreateDialogBoxStream);
  84.     URegistrar::RegisterClass(LStdButton::class_ID, LStdButton::CreateStdButtonStream);
  85.     URegistrar::RegisterClass(LStdCheckBox::class_ID, LStdCheckBox::CreateStdCheckBoxStream);
  86.     URegistrar::RegisterClass(LStdRadioButton::class_ID, LStdRadioButton::CreateStdRadioButtonStream);
  87.     URegistrar::RegisterClass(LButton::class_ID, LButton::CreateButtonStream);
  88.     URegistrar::RegisterClass(LCaption::class_ID, LCaption::CreateCaptionStream);
  89.     URegistrar::RegisterClass(LRadioGroup::class_ID, LRadioGroup::CreateRadioGroupStream);
  90.     URegistrar::RegisterClass(LEditField::class_ID, LEditField::CreateEditFieldStream);
  91.     URegistrar::RegisterClass(LStdPopupMenu::class_ID, LStdPopupMenu::CreateStdPopupMenuStream);
  92.  
  93.         //    Register the functions to create our custom Pane classes
  94.  
  95.     URegistrar::RegisterClass(CDimmerCluster::class_ID, CDimmerCluster::CreateDimmerStream);
  96.     URegistrar::RegisterClass(CDimmableEditText::class_ID, CDimmableEditText::CreateDimmableEditTextStream);
  97.     URegistrar::RegisterClass(CDimCaption::class_ID, CDimCaption::CreateDimCaptionStream);
  98. }
  99.  
  100.  
  101. // ---------------------------------------------------------------------------
  102. //        • ~CDimmerApp
  103. // ---------------------------------------------------------------------------
  104. //    Destructor
  105. //
  106.  
  107. CDimmerApp::~CDimmerApp()
  108. {
  109. }
  110.  
  111. // ---------------------------------------------------------------------------
  112. //        • StartUp
  113. // ---------------------------------------------------------------------------
  114. //    This function lets you do something when the application starts up. We'll
  115. //    bring up the Standard Controls window.
  116. //
  117.  
  118. void
  119. CDimmerApp::StartUp()
  120. {
  121.     ObeyCommand(cmd_OpenDimmerDlg, nil);
  122. }
  123.  
  124. // ---------------------------------------------------------------------------
  125. //        • ObeyCommand
  126. // ---------------------------------------------------------------------------
  127. //    This function handles menu commands.
  128. //
  129.  
  130. Boolean
  131. CDimmerApp::ObeyCommand(
  132.     CommandT    inCommand,
  133.     void        *ioParam)
  134. {
  135.     Boolean            cmdHandled = true;
  136.     LDialogBox        *theWindow;
  137.     LEditField        *theText;
  138.  
  139.     switch (inCommand) {
  140.         
  141.         case cmd_OpenDimmerDlg:
  142.             theWindow    = (LDialogBox*)LWindow::CreateWindow(rDimmerDlgID, this);
  143.  
  144.                 // set up text field as the initial target
  145.             theText        = (LEditField*)theWindow->FindPaneByID('edt1');
  146.             theWindow->SetLatentSub(theText);
  147.             
  148.             theWindow->Show();
  149.             break;    
  150.             
  151.         default:
  152.             cmdHandled    = LApplication::ObeyCommand(inCommand, ioParam);
  153.             break;
  154.     }
  155.  
  156.     return cmdHandled;
  157. }
  158.  
  159.  
  160. // ---------------------------------------------------------------------------
  161. //        • FindCommandStatus
  162. // ---------------------------------------------------------------------------
  163. //    This function enables menu commands.
  164. //
  165.  
  166. void
  167. CDimmerApp::FindCommandStatus(
  168.     CommandT    inCommand,
  169.     Boolean        &outEnabled,
  170.     Boolean        &outUsesMark,
  171.     Char16        &outMark,
  172.     Str255        outName)
  173. {
  174.     outUsesMark = false;
  175.  
  176.     switch (inCommand) {
  177.  
  178.         case cmd_Open:
  179.         case cmd_New:
  180.             outEnabled = false;
  181.             break;
  182.             
  183.         case cmd_OpenDimmerDlg:
  184.             outEnabled = true;
  185.             break;
  186.  
  187.         default:
  188.             LApplication::FindCommandStatus(inCommand, outEnabled,
  189.                                             outUsesMark, outMark, outName);
  190.             break;
  191.     }
  192. }
  193.